package StudyCode.summary.myfile;

import java.io.File;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class WildcardComma {
	public static void main(String[] argv) throws Exception {
		String pWildcardPath = "tah1986.com";
		System.out.println(java.util.Arrays.toString(listFiles(pWildcardPath)));
	}

	public static String[] listFiles(String pWildcardPath) {
		if (pWildcardPath.contains(",")) {
			String[] files = pWildcardPath.split(",");
			return files;
		}
		if (pWildcardPath.contains("*")) {
			return dirList(pWildcardPath);
		}
		return new String[]{pWildcardPath};
	}

	private static String[] dirList(String fname) {
		if (isWindows()) {
			fname = fname.replace('\\', '/');
		}
		String dirPath = "";
		if (fname.contains("/")) {
			int lPosFilename = fname.lastIndexOf("/");
			dirPath = fname.substring(0, lPosFilename + 1);
			fname = fname.substring(lPosFilename + 1);
		}
		File dir = new File(dirPath);
		return null;
//		return dir.list(new WildCardFileFilter(fname));
	}

	private static boolean isWindows() {
		return System.getProperty("os.name").toLowerCase().indexOf("win") >= 0;
	}
}
